package com.hzhk.happyrent.ui.holder;

import android.content.Context;
import android.view.View;
import android.widget.Toast;



public class BaseViewHolder {
	public Context context;
	public View view;
	public final <E extends View> E getView (int id) {
	    try {
	        return (E) view.findViewById(id);
	    } catch (ClassCastException ex) {
	        throw ex;
	    }
	}
	public String getString(int id){
		return context.getString(id);
	}
	public int getResCoclor(int id) {
		return context.getResources().getColor(id);
	}

	public Float getDimens(int id) {
		return context.getResources().getDimension(id);
	}
	protected int getDimensInt(int id) {
		return context.getResources().getDimensionPixelSize(id);
	}
	/**
	 * 显示toast
	 */
	private Toast mToast;
	protected void showToast(String msg) {
		try {
			if (null == mToast)
				mToast = Toast.makeText(context, "", Toast.LENGTH_SHORT);
			mToast.setText(msg);
			mToast.show();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
